package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingHeartRate;
import com.ruoyi.ring.service.IRingHeartRateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 心率
 * 
 * @author liuwp
 * @date 2025-08-21
 */
@RestController
@RequestMapping("/ring/ring_heart_rate")
public class RingHeartRateController extends BaseController
{
    @Autowired
    private IRingHeartRateService ringHeartRateService;

    /**
     * 查询心率列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_heart_rate:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingHeartRate ringHeartRate)
    {
        startPage();
        List<RingHeartRate> list = ringHeartRateService.selectRingHeartRateList(ringHeartRate);
        return getDataTable(list);
    }

    /**
     * 导出心率列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_heart_rate:export')")
    @Log(title = "心率", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingHeartRate ringHeartRate)
    {
        List<RingHeartRate> list = ringHeartRateService.selectRingHeartRateList(ringHeartRate);
        ExcelUtil<RingHeartRate> util = new ExcelUtil<RingHeartRate>(RingHeartRate.class);
        util.exportExcel(response, list, "心率数据");
    }

    /**
     * 获取心率详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_heart_rate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringHeartRateService.selectRingHeartRateById(id));
    }

    /**
     * 新增心率
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_heart_rate:add')")
    @Log(title = "心率", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingHeartRate ringHeartRate)
    {
        return toAjax(ringHeartRateService.insertRingHeartRate(ringHeartRate));
    }

    /**
     * 修改心率
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_heart_rate:edit')")
    @Log(title = "心率", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingHeartRate ringHeartRate)
    {
        return toAjax(ringHeartRateService.updateRingHeartRate(ringHeartRate));
    }

    /**
     * 删除心率
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_heart_rate:remove')")
    @Log(title = "心率", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringHeartRateService.deleteRingHeartRateByIds(ids));
    }

}
